package com.ws.boot.demo.validate.service.method.parameter.impl;

import com.ws.boot.demo.validate.entity.Person;
import com.ws.boot.demo.validate.service.method.parameter.MethodParameterForCollectionService;
import com.ws.boot.web.domain.DefaultResponse;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Map;

/**
 * 方法参数 业务类 ： 复杂数据结构（单层泛型） Map，List，Array 实现类 .
 *
 * @className: MethodParameterForCollectionServiceImpl
 * @author: ws
 * @date: 2020/4/2 14:17
 * @version: 1.0.0
 */
@Service
public class MethodParameterForCollectionServiceImpl implements MethodParameterForCollectionService {

    /**
     * map 单层泛型 .
     *
     * @param username
     * @param map
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 14:20
     **/
    @Override
    public DefaultResponse map(@NotBlank String username, @NotNull @Size(min = 2) Map<@NotBlank String, @NotNull Object> map) {
        return DefaultResponse.success();
    }

    /**
     * list 单层泛型 .
     *
     * @param list
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 14:23
     **/
    @Override
    public DefaultResponse list(@NotNull @Size(min = 1, max = 3) List<@NotNull Long> list) {
        return DefaultResponse.success();
    }

    /**
     * 数组结合POJO .
     *
     * @param array
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 14:25
     **/
    @Override
    public DefaultResponse array(@NotEmpty @Size(max = 5) Person[] array) {
        return DefaultResponse.success();
    }
}
